package cmd

import (
	"context"
	"go_muban/utility"

	"github.com/gogf/gf/v2/frame/g"
)

type CMain struct {
	g.Meta `name:"main" root:"http"`
}

type cMainHttpInput struct {
	g.Meta `name:"http" brief:"start http server"`
}
type cMainHttpOutput struct{}

type cMainCollectInput struct {
	g.Meta `name:"collect" brief:"start collect job"`
}
type cMainCollectOutput struct{}

func (c *CMain) Http(ctx context.Context, in cMainHttpInput) (out *cMainHttpOutput, err error) {
	s := g.Server()

	// 注册路由
	RegisterRouters(s)

	s.Run()
	return
}

func (c *CMain) Collect(ctx context.Context, in cMainCollectInput) (out *cMainCollectOutput, err error) {
	utility.StartCollect("https://sc.chinaz.com/moban/index.html")
	return
}
